package cn.stylefeng.guns.modular.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;

import com.alibaba.druid.support.json.JSONUtils;

import cn.stylefeng.guns.modular.util.json.JsonUtils;

public class HttpSend {

	public static void send(String pushId,String type,String title){
		RestTemplate restTemplate = new RestTemplate();
		List<String> list = new ArrayList<String>();
		list.add(pushId);
		String url = "https://www.idjglobalapp.com/app-servce/v1/api/push/send-notice";
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("type", type);
		HashMap<String, Object> maps = new HashMap<String, Object>();
		maps.put("pushId", list);
		maps.put("title", title);
		maps.put("content", JSONUtils.toJSONString(map));
		String requestVo = JsonUtils.toJson(maps);
		HttpEntity request = new HttpEntity<>(requestVo, headers);
		restTemplate.exchange(url, HttpMethod.POST, request, String.class);
	}
}
